package net.sf.pulse.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;

/**
 * Provide a way to either select channels to add to the {@link Monitor monitor panel} out of automatically
 * discovered local channels, or manually specify the channel descriptor or meta-descriptor. 
 */
public class AddChannel extends Activity {
	
	public static final int MENU_ID_ADD_CHANNEL = Menu.FIRST;

	private static final int ACTIVITY_CONFIGURE_CHANNEL = 0;

	private ListView channelsConfigured;
	private ListView channelsDiscovered;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.channel_add);
      
        channelsConfigured = (ListView)findViewById(R.id.channels_configured);
        channelsDiscovered = (ListView)findViewById(R.id.channels_discovered);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        boolean result = super.onCreateOptionsMenu(menu);
        menu.add(0,MENU_ID_ADD_CHANNEL, 0, R.string.channel_add);
        return result;
    }

	@Override
    public boolean onOptionsItemSelected(MenuItem item) {

		switch (item.getItemId()) {
		case MENU_ID_ADD_CHANNEL:
			addChannel();
			return true;
		}
		return super.onOptionsItemSelected(item);
    }

	/**
	 * Invoke the activity that provides new static channel configuration and augments the
	 * persistent data storage with it. Upon return, refresh the list of configured channels.
	 */
	private void addChannel() {
		Intent i = new Intent(this, ConfigureChannel.class);
		startActivityForResult(i, ACTIVITY_CONFIGURE_CHANNEL);
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
	}
}
